package com.neusoft.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.neusoft.dao.RoleAuthDao;
import com.neusoft.entity.RoleAuth;
import com.neusoft.service.RoleAuthService;
import com.neusoft.util.StringUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (RoleAuth)表服务实现类
 *
 * @author makejava
 * @since 2020-06-05 20:49:57
 */
@Service("roleAuthService")
public class RoleAuthServiceImpl implements RoleAuthService {
    @Resource
    private RoleAuthDao roleAuthDao;

    public IPage<RoleAuth> queryAllByLimit(int offset, int limit, RoleAuth roleAuth) {
        Page<RoleAuth> page=new Page<>(offset,limit);
//        QueryWrapper<Admin> wrapper=new QueryWrapper<>();
//        wrapper.like("account",admin.getAccount())
//                .eq("password",admin.getPassword())
//                .gt("phone",admin.getPhone());
        page.setRecords(roleAuthDao.queryAll(page,roleAuth));
        return page;
    }
    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public RoleAuth queryById(Integer id) {
        return this.roleAuthDao.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<RoleAuth> queryAllByLimit(int offset, int limit) {
        return this.roleAuthDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param roleAuth 实例对象
     * @return 实例对象
     */
    @Override
    public RoleAuth insert(RoleAuth roleAuth) {
        this.roleAuthDao.insert(roleAuth);
        return roleAuth;
    }

    /**
     * 修改数据
     *
     * @param roleAuth 实例对象
     * @return 实例对象
     */
    @Override
    public int update(RoleAuth roleAuth) {

        return this.roleAuthDao.update(roleAuth);
    }


    @Override
    public boolean deleteById(List<Integer> ids)
    {System.out.println("delete");
        return this.roleAuthDao.delete("hotelbookidea.role_auth", StringUtil.deleteWhere(ids)) > 0;
    }
}